<form class="layui-form layui-form-pamel" name="form1" id="form1" method="post">
    <div class="searchbox demoTable" id="searchbox">
        <input type="button" value="查询" onclick="searchs();" class="layui-btn layui-btn-red fr mr10"/>
        <input type="text" name="keywords" id="keywords" placeholder="请输入关键字" class="layui-input layui-input-search fr mr10">
    </div>
</form>
    <div style="overflow:auto;width: 100%;padding-bottom: 20px;">
        <table id="simple-table" class="layui-table" lay-filter="simple-table">
        </table>
        <script type="text/html" id="barTable">

            <a class="layui-icon colored7764" lay-event="del" title="删除">&#xe640;</a>
        </script>
    </div>
<script type="text/javascript">
    var formTable;
    var table;
    var form;
    layui.use(['form','table','laydate','util'], function(){
        form = layui.form;
        table = layui.table;
        var util = layui.util;
        form.render();

        formTable = table.render({
            elem: '#simple-table',
            url:'${basePath}system/log/getlogoperatelistPage',
            request: {
                pageName: 'currentPage' //页码的参数名称，默认：page
                ,limitName: 'showCount' //每页数据量的参数名，默认：limit
            },
            response: {
                statusName: 'status' //数据状态的字段名称，默认：code
                ,statusCode: true //成功的状态码，默认：0
                ,msgName: 'msg' //状态信息的字段名称，默认：msg
                ,countName: 'totalResult' //数据总数的字段名称，默认：count
                ,dataName: 't' //数据列表的字段名称，默认：data
            },
            cols: [[
                 {field:'logLevel', title: '级别'}
                ,{field:'logModule', title: '功能模块'}
                ,{field:'logDesc', title: '操作名称'}
                ,{field:'parameter', title: '参数'}
                ,{field:'logPath', title: '操作路径'}
                ,{field:'userName', title: '操作用户'}
                ,{field:'deptName', title: '部门'}
                ,{field:'userIp', title: '用户IP'}
                ,{field:'logDate', title: '操作时间',templet:function (d) {
                        return util.toDateString(d.logDate,"yyyy-MM-dd hh:mm:ss")
                    }}
            ]],
            page: true
        });
        table.on('tool(simple-table)', function(obj){
            var data = obj.data;
            if(obj.event === 'limit'){
                editRights(data.roleId);
            } else if(obj.event === 'del'){
                layer.confirm('真的删除<span style="color: #9f191f">'+data.roleName+'</span>吗?', function(index){
                    $.ajax({
                        url : '${basePath}system/role/deleteRole',
                        data : {
                            roleId : data.roleId,
                            roleCode : data.roleCode
                        },
                        type : "POST",
                        success : function(data) {
                            if (data.status == true) {
                                obj.del(); //删除表格里的行
                                layer.close(index);
                                searchs();
                            } else {
                                layer.alert(data.msg);
                            }
                        }
                    });
                });
            } else if(obj.event === 'edit'){
                editRole(data.roleId);
            }
        });
    });

    //检 索
    function searchs() {
        formTable.reload({
            where: {
                keywords: $("#keywords").val()
            },page: {
                curr: 1 //重新从第 1 页开始
            }
        });
    }

</script>
